import { http } from '@/utils/http'

/**
 * 加入购物车
 * @param data 请求体参数
 */
export const postMemberCartAPI = (data: { productItemId: string | Number; quantity: number }) => {
  return http({
    method: 'POST',
    url: '/shop/consume/mobile/shop/cart',
    data,
  })
}

/**
 * 获取购物车列表
 */
export const getMemberCartAPI = (data: any) => {
  return http<any[]>({
    method: 'GET',
    url: '/shop/consume/mobile/shop/cart/list',
    data,
  })
}

/**
 * 删除/清空购物车单品
 * @param data 请求体参数 ids  集合
 */
export const deleteMemberCartAPI = (ids: any[]) => {
  return http({
    method: 'DELETE',
    url: '/shop/consume/mobile/shop/cart/' + ids,
  })
}

/**
 * 修改购物车单品
 * @param skuId SKUID
 * @param data selected 选中状态 count 商品数量
 */
export const putMemberCartBySkuIdAPI = (data: any) => {
  return http({
    method: 'PUT',
    url: `/shop/consume/mobile/shop/cart`,
    data,
  })
}

export const cartPriceByIdAPI = (ids: any[]) => {
  return http({
    method: 'GET',
    url: `/shop/consume/mobile/shop/cart/price/` + ids,
  })
}

/**
 * 购物车全选/取消全选
 * @param data selected 是否选中
 */
export const putMemberCartSelectedAPI = (data: any) => {
  return http({
    method: 'PUT',
    url: '/shop/consume/mobile/shop/cart',
    data,
  })
}
